package hibernate.model;

import static javax.persistence.GenerationType.IDENTITY;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.NamedQueries;
import org.hibernate.annotations.NamedQuery;

@SuppressWarnings("serial")
@Entity
@Table(name = "adres", catalog = "emmy")
@NamedQueries({  // şimdilik bu query'lere gerek yok ihtiyaç olursa diye hazırlandı...
@NamedQuery(name = "findAdresGid", query = "from Adres where grupid = :agid"),
@NamedQuery(name = "findAdresil", query = "from Adres where il like :ail"),
@NamedQuery(name = "findAdresilce", query = "from Adres where ilce like :ailce"),
@NamedQuery(name = "findAdresMahalle", query = "from Adres where mahalle like :ailmahalle"),
@NamedQuery(name = "findAdresSokak", query = "from Adres where sokak like :asokak"),
@NamedQuery(name = "findAdresNumara", query = "from Adres where numara = :anumara")
})
public class Adres implements java.io.Serializable {

	private Long adresid;
	private int grupid;
	private String il;
	private String ilce;
	private String mahalle;
	private String sokak;
	private String numara;
	private Set<Temsilci> temsilcis = new HashSet<Temsilci>(0);
	private Set<Musteri> musteris = new HashSet<Musteri>(0);

	public Adres() {
	}

	public Adres(int grupid, String il, String ilce, String mahalle,
			String sokak, String numara) {
		this.grupid = grupid;
		this.il = il;
		this.ilce = ilce;
		this.mahalle = mahalle;
		this.sokak = sokak;
		this.numara = numara;
	}

	public Adres(int grupid, String il, String ilce, String mahalle,
			String sokak, String numara, Set<Temsilci> temsilcis,
			Set<Musteri> musteris) {
		this.grupid = grupid;
		this.il = il;
		this.ilce = ilce;
		this.mahalle = mahalle;
		this.sokak = sokak;
		this.numara = numara;
		this.temsilcis = temsilcis;
		this.musteris = musteris;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "adresid", unique = true, nullable = false)
	public Long getAdresid() {
		return this.adresid;
	}

	public void setAdresid(Long adresid) {
		this.adresid = adresid;
	}

	@Column(name = "grupid", nullable = false)
	public int getGrupid() {
		return this.grupid;
	}

	public void setGrupid(int grupid) {
		this.grupid = grupid;
	}

	@Column(name = "il", nullable = false, length = 20)
	public String getIl() {
		return this.il;
	}

	public void setIl(String il) {
		this.il = il;
	}

	@Column(name = "ilce", nullable = false, length = 20)
	public String getIlce() {
		return this.ilce;
	}

	public void setIlce(String ilce) {
		this.ilce = ilce;
	}

	@Column(name = "mahalle", nullable = false, length = 50)
	public String getMahalle() {
		return this.mahalle;
	}

	public void setMahalle(String mahalle) {
		this.mahalle = mahalle;
	}

	@Column(name = "sokak", nullable = false, length = 50)
	public String getSokak() {
		return this.sokak;
	}

	public void setSokak(String sokak) {
		this.sokak = sokak;
	}

	@Column(name = "numara", nullable = false, length = 10)
	public String getNumara() {
		return this.numara;
	}

	public void setNumara(String numara) {
		this.numara = numara;
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "adres")
	public Set<Temsilci> getTemsilcis() {
		return this.temsilcis;
	}

	public void setTemsilcis(Set<Temsilci> temsilcis) {
		this.temsilcis = temsilcis;
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "adres")
	public Set<Musteri> getMusteris() {
		return this.musteris;
	}

	public void setMusteris(Set<Musteri> musteris) {
		this.musteris = musteris;
	}
}